///导入heatmap
import Heatmap from "heatmap.js";
///设置
function setmapValue(SetValue, posx, posy, Level) {
	if (SetValue) {
		if (Level == 1) {
			LevelOne();
		}
		if (Level == 2) {
			LevelTwo();
		}
		if (Level == 3) {
			LevelThree();
		}
	} else {
		var points = [];
		var heatmapInstance = Heatmap.create({
			container: document.getElementById("myDiagramDiv"),
			backgroundColor: '#f0f0f0',
		});
		var point = {
			x: posx,
			y: posy,
			value: 0
		};
		points.push(point);
		var data = {
			max: 0,
			data: 0
		};
		// 因为data是一组数据,web切图报价所以直接setData
		heatmapInstance.setData(data);
	}
	///绘制一等级热力图
	function LevelOne() {
		var points = [];
		var heatmapInstance = Heatmap.create({
			container: document.getElementById("myDiagramDiv"),
			//backgroundColor: 'pink',
			// opacity:0.6,
			radius: 250,
			gradient: {
				".4": "#91C802",
				".6": "#FEFF01"
			}
		});
		var point = {
			x: posx,
			y: posy,
			value: 0
		};
		points.push(point);
		var data = {
			max: 0,
			data: points
		};
		// 因为data是一组数据,web切图报价所以直接setData
		heatmapInstance.setData(data);
	}

	///绘制二等级热力图
	function LevelTwo() {
		var points = [];
		var heatmapInstance = Heatmap.create({
			container: document.getElementById("myDiagramDiv"),
			//backgroundColor: 'pink',
			// opacity:0.6,
			radius: 260,
			gradient: {
				".4": "#91C802",
				".6": "#FEFF01",
				".9": "#FC7831"
			}
		});
		var point = {
			x: posx,
			y: posy,
			value: 0
		};
		points.push(point);
		var data = {
			max: 0,
			data: points
		};
		// 因为data是一组数据,web切图报价所以直接setData
		heatmapInstance.setData(data);
	}
	///绘制三等级热力图
	function LevelThree() {
		var points = [];
		var heatmapInstance = Heatmap.create({
			container: document.getElementById("myDiagramDiv"),
			//backgroundColor: 'pink',
			// opacity:0.6,
			radius: 280,
			gradient: {
				".4": "green",
				".6": "yellow",
				".9": "red"
			}
		});
		var point = {
			x: posx,
			y: posy,
			value: 0
		};
		points.push(point);
		var data = {
			max: 0,
			data: points
		};
		// 因为data是一组数据,web切图报价所以直接setData
		heatmapInstance.setData(data);
	}
}

export {
	setmapValue
}
